package com.zhihaoliang.coroutine.buss.concurrent.func

import com.zhihaoliang.coroutine.buss.concurrent.massiveRun
import com.zhihaoliang.coroutine.util.log
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.util.concurrent.atomic.AtomicInteger

/**
 * @author 支豪亮
 * @date 2022/10/31 16:09
 * @des 数据整理
 */
object AtomicIntegerData {
    fun atomicData(mainScope: CoroutineScope) = mainScope.launch(Dispatchers.Default) {
        val counter = AtomicInteger()
        massiveRun {
            counter.incrementAndGet()
        }
        log("Counter = $counter")
    }
}